# -*- coding: utf-8 -*-
"""
__title__ = ''
__author__ = 'Yang'
__mtime__ = '2019/2/16 22:04'
# code is far away from bugs with the god animal protecting
    I love animals. They taste delicious.
              ┏┓      ┏┓
            ┏┛┻━━━┛┻┓
            ┃      ☃      ┃
            ┃  ┳┛  ┗┳  ┃
            ┃      ┻      ┃
            ┗━┓      ┏━┛
                ┃      ┗━━━┓
                ┃  神兽保佑    ┣┓
                ┃　永无BUG！   ┏┛
                ┗┓┓┏━┳┓┏┛
                  ┃┫┫  ┃┫┫
                  ┗┻┛  ┗┻┛
"""
import json

with open('jd_data.csv', encoding="utf-8") as f:
    res = []
    while True:
        line = f.readline().replace("\n", '')
        if not line:
            break

        lines = line.split(',')

        tmp = {}

        tmp['goods_id'] = lines[0]
        tmp['shop_name'] = lines[1]
        tmp['pro_name'] = lines[2]
        tmp['price'] = lines[3]
        tmp['shop_star'] = lines[4]
        tmp['shop_goods_score'] = lines[5]
        tmp['shop_logistics_score'] = lines[6]
        tmp['shop_after_sale_score'] = lines[7]
        tmp['comment_count'] = lines[8]
        tmp['good_count'] = lines[9]
        tmp['good_rate'] = lines[10]
        res.append(tmp)
    data = json.dumps(res, ensure_ascii=False)

    fp = open('jd.json', 'a', encoding="UTF-8")
    fp.write(data)

# tmp['goods_id']
# tmp['shop_name']
# tmp['pro_name']
# tmp['price']
# tmp['shop_star']
# tmp['shop_goods_score']
# tmp['shop_logistics_score']
# tmp['shop_after_sale_score']
# tmp['comment_count']
# tmp['good_count']
# tmp['good_rate']
